package cn.zaichi.edu.excelcommon.plugs.validation;

import cn.zaichi.edu.excelcommon.error.ValidatorExceptionEnum;
import cn.zaichi.edu.excelcommon.exception.ValidatorException;
import cn.zaichi.edu.excelcommon.plugs.Validator;
import cn.zaichi.edu.excelcommon.utils.ValidateIdCardUtil;

/**
 * 验证身份证格式
 */
public class IdCardValidator implements Validator {

  @Override
  public void valid(Object value) {
    if(value==null){
      return;
    }
    if(!ValidateIdCardUtil.isIDCard(value.toString())){
      throw new ValidatorException(ValidatorExceptionEnum.VALIDATOR_IDCARD);
    }
  }

}
